Skip to content
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

Add debug logging to compiler module #1280

Merged
merged 1 commit into from Sep 25, 2023
Merged

Add debug logging to compiler module #1280

merged 1 commit into from Sep 25, 2023

Conversation

ianthomas23
Copy link
Member

@ianthomas23 ianthomas23 commented Sep 21, 2023

Fixes #1266.

This adds some debug logging to the compiler.py module to show the dynamically-generated Python code that is subsequently compiled by numba. By default logging is disabled, and when it is enabled an example of the logged output for an antialiased ds.where(ds.min("value"), "other") reduction is

def aa_stage_2_accumulate(aggs_and_copies, first_pass):
    if first_pass:
        for a in literal_unroll(aggs_and_copies):
            a[1][:] = a[0][:]
    else:
        combine0(aggs_and_copies[1][::-1], aggs_and_copies[0][::-1])
def aa_stage_2_clear(aggs_and_copies):
    aggs_and_copies[0][0].fill(nan)
    aggs_and_copies[1][0].fill(nan)
global_cuda_mutex False
any_uses_cuda_mutex False
arg_lk _0 <datashader.reductions.min object at 0x17461f350> value
arg_lk _1 <datashader.reductions.where object at 0x17461f390> other
arg_lk _2 <datashader.reductions.extract object at 0x174634990> value
arg_lk _3 <datashader.reductions.extract object at 0x1746349d0> other
func _4 CPUDispatcher(<function min._append_antialias at 0x17285b560>)
func _5 CPUDispatcher(<function where._append_antialias at 0x174119300>)
def append(i0, x, y, aa_factor, _0, _1, _2, _3):
    _6 = _4(x, y, _0, _2[i0], aa_factor)
    if _6 >= 0:
        _5(x, y, _1, _3[i0], aa_factor, _6)

To enable logging in a user script use

import logging
logger = logging.getLogger("datashader.compiler")
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())

This is the standard approach and is a bit verbose but suffices for the moment. In future we could consider adding a new setup_logging function that does all of this in a one-liner.

@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

Merging #1280 (cb41f58) into main (3dab9df) will decrease coverage by 0.03%.
The diff coverage is 63.63%.

@@            Coverage Diff             @@
##             main    #1280      +/-   ##
==========================================
- Coverage   83.54%   83.52%   -0.03%     
==========================================
  Files          35       35              
  Lines        9134     9145      +11     
==========================================
+ Hits         7631     7638       +7     
- Misses       1503     1507       +4     
Files Changed Coverage Δ
datashader/compiler.py 88.85% <63.63%> (-0.95%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ianthomas23 ianthomas23 merged commit 3d9cefc into holoviz:main Sep 25, 2023
14 of 16 checks passed
@ianthomas23 ianthomas23 deleted the compiler_logging branch September 25, 2023 09:09
@ianthomas23 ianthomas23 added this to the v0.15.3 milestone Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add logging to compiler.py
1 participant