Skip to content

Add example of how to enable profiling for executables and libraries to docs #793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
codygman opened this issue Jul 28, 2020 · 3 comments
Closed

Comments

@codygman
Copy link

I think this is correct (my in progress build with *.p_o implies so at least):

pkgs.haskell-nix.project {
  # 'cleanGit' cleans a source directory based on the files known by git
  projectFileName = "cabal.project";
  src = pkgs.haskell-nix.haskellLib.cleanGit {
    name = "haskell-language-server";
    src = ./.;
  };
  modules = [
    { enableExecutableProfiling = true; }
  ];
  # For `cabal.project` based projects specify the GHC version to use.
  compiler-nix-name = "ghc884"; # Not used for `stack.yaml` based projects.
}

How does that work actually? If nothing is specified in any list of the module list the value applies to all?

@codygman
Copy link
Author

codygman commented Aug 13, 2020

It looks like this is going to do the trick for adding profiling to haskell-language-server installed via hls-nix:

(hls { version = "8.8.3"; }).exes.haskell-language-server.override(_: {enableExecutableProfiling = true;});
Full shell.nix
{...}:

let
  sources = import ./nix/sources.nix;
  pkgs = import sources.nixpkgs {};
  hls  = import sources.hls-nix;
  hsPkgs = import ./default.nix {};
  hlsWithProfilng = (hls { version = "8.8.3"; }).exes.haskell-language-server.override(_: {enableExecutableProfiling = true;});
in
  hsPkgs.shellFor {
    # Include only the *local* packages of your project.
    packages = ps: with ps; [
      mylib
    ];

    # Builds a Hoogle documentation index of all dependencies,
    # and provides a "hoogle" command to search the index.
    withHoogle = true;

    # You might want some extra tools in the shell (optional).

    # Some common tools can be added with the `tools` argument
    tools = { cabal = "3.2.0.0"; hlint = "2.2.11"; brittany = "0.12.1.1";};
    # See overlays/tools.nix for more details

    # Some you may need to get some other way.
    buildInputs = with pkgs.haskellPackages;
      [ hspec-discover stack ghcid pkgs.postgresql hlsWithProfilng ];

    # Prevents cabal from choosing alternate plans, so that
    # *all* dependencies are provided by Nix.
    exactDeps = true;
  }

@brprice
Copy link

brprice commented Sep 19, 2021

I find that (at least, when using flakes) this (enableExecutableProfiling = true) is not a full solution.

Whilst it works to profile

  • via nix run
  • via cabal in a nix develop shell when there are no (non-boot) external dependencies

It does not work to profile via cabal in a nix develop shell when there are external dependencies (ghc complains that Could not find module ‘Data.HashMap.Lazy’ Perhaps you haven't installed the profiling libraries for package ‘unordered-containers-0.2.14.0’?)

To get profiling-via-cabal working, I found it sufficed to have

modules = [
    { enableExecutableProfiling = true;
      enableLibraryProfiling = true;
    }
  ];

(In the future, it seems that just adding profiling: True to cabal.project should work: see #887. However, it is currently broken. )

@stale
Copy link

stale bot commented Jan 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 18, 2023
@stale stale bot closed this as completed Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants