Ticket #11388 (closed defect: fixed)

Opened 2 years ago

Last modified 21 months ago

Allow start/stop recording exceptions in the coercion model

Reported by: robertwb Owned by: tbd
Priority: major Milestone: sage-4.7.2
Component: coercion Keywords: debug, coercion, exceptions
Cc: Work issues:
Report Upstream: N/A Reviewers: Luis Felipe Tabera Alonso
Authors: Robert Bradshaw Merged in: sage-4.7.2.alpha2
Dependencies: Stopgaps:

Description (last modified by lftabera) (diff)

This was detected in the following speed regression

In vanilla sage 4.6.2

sage: a=Integer(1000)
sage: b=int(1000)
sage: c=[0]
sage: %timeit c*a
625 loops, best of 3: 21.2 µs per loop
sage: %timeit c*b
625 loops, best of 3: 5.21 µs per loop

In vanilla sage 4.7.rc4

sage: a=Integer(1000)
sage: b=int(1000)
sage: c=[0]
sage: %timeit c*a
625 loops, best of 3: 568 µs per loop
sage: %timeit c*b
625 loops, best of 3: 5.13 µs per loop

By default the coercion model should not be recording exceptions ocurred in the execution of sage unless explicitely anabling reconding exceptions for debugging support.

Apply:

Attachments

11388-coercion-speed.patch Download (3.8 KB) - added by robertwb 2 years ago.
11388-coercion-speed.2.patch Download (3.8 KB) - added by robertwb 2 years ago.
11388-coercion-speed.3.patch Download (4.1 KB) - added by robertwb 2 years ago.
11388-coercion-speed-referee-patch.patch Download (976 bytes) - added by lftabera 22 months ago.

Change History

Changed 2 years ago by robertwb

comment:1 Changed 2 years ago by robertwb

  • Status changed from new to needs_review

comment:2 Changed 2 years ago by jdemeyer

  • Component changed from performance to coercion
  • Authors set to Robert Bradshaw

comment:3 Changed 2 years ago by jdemeyer

  • Status changed from needs_review to needs_work

Robert, I get a documentation warning, I would guess the docbuilder gets confused by the "\n" in the doctest:

docstring of sage.structure.coerce.CoercionModel_cache_maps.record_exceptions:11: (WARNING/2) Block quote ends without a blank line; unexpected unindent.

Changed 2 years ago by robertwb

comment:4 Changed 2 years ago by robertwb

  • Status changed from needs_work to needs_review

Patch updated.

comment:5 Changed 2 years ago by lftabera

  • Status changed from needs_review to needs_info

mmm, I do not get any improvement. I get exactly the same timmings as in the ticket with the patch. I have tried on a fresh sage-4.7

Robert, has the issue dissapeared for you with this patch?

comment:6 Changed 2 years ago by robertwb

OK, that's what comes of trying to add a patch in the middle of the night after a long day... it's missing a line. However, I think the fix at #11389 is better (rather than not record exceptions, we simply avoid them in many more cases).

Changed 2 years ago by robertwb

comment:7 Changed 2 years ago by lftabera

Ok, let me understand the code. There is a recording of exceptions that are very convenient for debugging. The problem is that it produces an important performance penalty. This is solved with record_exceptions() that controls the attribute _record_exceptions which is the flag that controls.

Just one thing. Each time that record_exceptions is called, the exception stack cached is cleared so:

sage: cm = sage.structure.element.get_coercion_model()
sage: cm.record_exceptions()
sage: cm._test_exception_stack()
sage: cm.record_exceptions()
sage: cm.exception_stack()
[]            

Is this the intended behavior? It is trivially seen from the code but I think it should be documented.

comment:8 Changed 2 years ago by jdemeyer

Are you continueing with this ticket or should it be closed?

comment:9 Changed 2 years ago by lftabera

  • Description modified (diff)
  • Summary changed from Speed regression in #10548 to Allow start/stop recording exceptions in the coercion model

No, this code is stull valid. The speed regression is gone, but the functions that control the record of the exceptions is still valid and worthy to include in sage.

Changed 22 months ago by lftabera

comment:10 Changed 22 months ago by lftabera

  • Keywords debug, coercion, exceptions added
  • Reviewers set to Luis Felipe Tabera Alonso
  • Status changed from needs_info to needs_review
  • Description modified (diff)

I give a positive review to the patch from Robert,

I just suggest some more verbosity in the documentation, as added in my patch.

comment:11 Changed 22 months ago by lftabera

  • Description modified (diff)

comment:12 Changed 22 months ago by jhpalmieri

  • Status changed from needs_review to positive_review

The only thing needing reviewing is the referee patch, right? Positive review.

comment:13 Changed 22 months ago by jdemeyer

  • Priority changed from critical to major
  • Milestone changed from sage-4.7.1 to sage-4.7.2

comment:14 Changed 21 months ago by jdemeyer

  • Status changed from positive_review to closed
  • Resolution set to fixed
  • Merged in set to sage-4.7.2.alpha2
Note: See TracTickets for help on using tickets.